<%@ page contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<%@ include file="/app/include.jsp"%>
		<script type="text/javascript">
			// 添加图片信息
			function add(){
				var diag = new Dialog();
				diag.URL = "${pageContext.request.contextPath}/app/data/insert-one-image.jsp";
				diag.Title = "添加图片信息";
				diag.Width = 800;
				diag.Height = 500;
				diag.OKEvent = function(){//点击确定后调用的方法
					var id = $("#id",diag.innerFrame.contentWindow.document).val();
					var namestr = $("#namestr",diag.innerFrame.contentWindow.document).val();
					var groupname = $("#groupname",diag.innerFrame.contentWindow.document).val();
					var keyword = $("#keyword",diag.innerFrame.contentWindow.document).val();
					var imagetype = $("#imagetype option:selected",diag.innerFrame.contentWindow.document).val();
					var memo = $("#memo",diag.innerFrame.contentWindow.document).val();
					if(namestr == null || namestr == ''){
					   alert('请输入名称!');
					   return;
					}
					if(keyword == null || keyword == ''){
					   alert('请输入关键字!');
					   return;
					}
					var formData = {
						"id" : isNotEmpty(id) ?encodeURIComponent(id)  : id,
						"namestr" : isNotEmpty(namestr) ?encodeURIComponent(namestr) : namestr,
						"groupname" : isNotEmpty(groupname) ?encodeURIComponent(groupname) : groupname,
						"keyword" : isNotEmpty(keyword) ?encodeURIComponent(keyword) : keyword,
						"imagetype" : isNotEmpty(imagetype) ?encodeURIComponent(imagetype) : imagetype,
						"memo" : isNotEmpty(memo) ?encodeURIComponent(memo) : memo
					};
					diag.innerFrame.contentWindow.beginUpload(formData); // 开始上传图片
				};
				diag.show();
			}
			 
			
			// 删除图片信息
			function del(id){
				var url = "${pageContext.request.contextPath}/datamanage/delImage.do";
				var params = {
					"id" : id
				};
				Tool.del(url,params);
			}
			function view(id){
 			    var url = '${pageContext.request.contextPath}/datamanage/viewImage.do?id=' + id;
				Tool.showDialog(url,'查看图片',800,600);
			}
		</script>	
			 
	</head>
	<body>
		<div class="right_content">
			<ul class="breadcrumb">
				<li>
					数据管理
					<span>/</span>
				</li>
				<li class="active">
					图片信息
				</li>
			</ul>
			<div class="list-wrap">
				<form id="queryForm" name="queryForm" action="${pageContext.request.contextPath}/datamanage/loadImageList.do">
					<div class="pull">
						<div class="pull-left">
							名称&nbsp;<input id="namestr" name="namestr" type="text" style="width: 240px;" value="${namestr}"/>
							关键词&nbsp;<input id="namestr" name="namestr" type="text" style="width: 240px;" value="${keyword}"/>
							类别&nbsp;<input id="namestr" name="namestr" type="text" style="width: 240px;" value="${catagory}"/>
						</div>
						<div class="pull-right">
							<input type="button" class="btn btn-primary" value="查询" onclick="Page.queryPage();"/>
							<input type="button" class="btn btn-primary" value="重置" onclick="Page.clearForm();"/>
							<input type="button" class="btn btn-primary" value="新增图片" onclick="add();"/>
						</div>
					</div>
				</form>
				<div class="table-wrap">
					<table border="0" cellpadding="0" cellspacing="0" class="list">
						<thead>
							<tr>
								<th width="5%">序号</th>
								<th>名称</th>
								<th width="25%">关键词</th>
								<th width="10%">类别</th>
								<th width="10%">操作人</th> 
								<th width="10%">创建时间</th> 
								<th width="15%">操作</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach var="result" items="${page.list}" varStatus="status">
							<tr>
								<td align="center">${page.pageSize * (page.pageNo - 1) + status.index + 1 }</td>
								<td><a href="javascript:void(0);" onclick="view('${result.id }');">${result.namestr}</a></td>
								<td>${result.keyword}</td>
								<td><open:out valueset="[图片类别]" value="${result.imagetype}" /></td>
								<td>${result.username}</td>
								<td>${result.opertime}</td>
								<td align="center">
									<a href="javascript:void(0);" onclick="view('${result.id }');">查看</a>&nbsp;&nbsp; 
									<a href="javascript:void(0);" onclick="del('${result.id }');">删除</a>
								</td>
							</tr>
							</c:forEach>
							<c:if test="${fn:length(page.list) == 0}">
								<tr>
									<td colspan=7 align="center"><font color=red><strong>没有图片！</strong></font></td>
								</tr>
							</c:if>
						</tbody>
					</table>
				</div> 
				<!--分页开始-->
				${page.operate }
				<!--/分页结束-->
			</div>
		</div>
	</body>
</html>